<template>
    <div>
        <div style="height: 20px;"></div>
        <!-- 搜索栏 -->
        <van-search v-model="value" shape="round" background="orangered" placeholder="请输入搜索关键词" @click="dj" />

        <!-- 标签栏 -->
        <van-tabs v-model:active="active">
            <van-tab title="推荐"></van-tab>
            <van-tab title="特惠"></van-tab>
            <van-tab title="美妆"></van-tab>
            <van-tab title="零食"></van-tab>
        </van-tabs>

        <!-- 轮播 懒加载 -->
        <van-swipe :autoplay="3000" lazy-render>
            <van-swipe-item v-for="item in swiperdata" :key="image">
                <img :src="item.image_src" style="width: 100%; height: 200px;" />
            </van-swipe-item>
        </van-swipe>

        <!-- 导航 -->
        <van-grid :column-num="4">
            <van-grid-item v-for="item in catitems" :icon="item.image_src" :text="item.name" />
        </van-grid>
        <van-grid :column-num="4">
            <van-grid-item v-for="item in catitems" :icon="item.image_src" :text="item.name" />
        </van-grid>

        <!-- 楼层  -->
        <div v-for="item in floordata">
            <img :src="item.floor_title.image_src" alt="" style="width: 100%;">
            <div v-for="item in item.product_list">
                <img :src="item.image_src" alt="" style="width: 100%; height: 200px;">
            </div>
        </div>
    </div>
</template>

<script setup>
const active = ref(0);
import { catitemsApi, floordataApi, swiperdataApi } from '@/api/api';
import { ref } from 'vue';
import router from '@/router';

const images = [
    'https://fastly.jsdelivr.net/npm/@vant/assets/apple-1.jpeg',
    'https://fastly.jsdelivr.net/npm/@vant/assets/apple-2.jpeg',
];

// 轮播渲染
let swiperdata = ref([])
swiperdataApi().then(res => {
    console.log('轮播', res);
    swiperdata.value = res.data.message
})

// 导航渲染
let catitems = ref([])
catitemsApi().then(res => {
    console.log('导航', res);
    catitems.value = res.data.message
})

// 楼层渲染
let floordata = ref([])
floordataApi().then(res => {
    console.log('楼层', res);
    floordata.value = res.data.message

})
const dj = () => {
    router.push('/home/index')
}
</script>

<style lang="scss" scoped></style>